<?php

namespace App\Entity\Shop;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Base\Annotation\Common;
use App\Repository\Shop\ShopProductStorageRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ORM\Entity(repositoryClass=ShopProductStorageRepository::class)
 */
class ShopProductStorage
{
    /**
     * @Common(cnName="#",listType="text",editType="text")
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @Groups({"prod","product"})
     */
    private $id;

    /**
     * @Common(cnName="产品",listType="text",editType="entity",width="")
     * @ORM\ManyToOne(targetEntity=ShopProduct::class, inversedBy="storages")
     * @ORM\JoinColumn(nullable=false)
     * @Groups({"prod","product"})
     */
    private $product;

    /**
     * @Common(cnName="数量",listType="text",editType="text",width="120")
     * @ORM\Column(type="float")
     * @Groups({"prod","product"})
     */
    private $num;

    /**
     * @Common(cnName="售价",listType="text",editType="text",width="120")
     * @ORM\Column(type="float")
     * @Groups({"prod","product"})
     */
    private $price;

    /**
     * @Common(cnName="会员价",listType="text",editType="text",width="120")
     * @ORM\Column(type="float", nullable=true)
     * @Groups({"prod","product"})
     */
    private $priceSale;

    /**
     * @Common(cnName="成本价",listType="text",editType="text",width="120")
     * @ORM\Column(type="float", nullable=true)
     * @Groups({"prod","product"})
     */
    private $priceCost;

    /**
     * @Common(cnName="查询文本",listType="text",editType="text",width="300")
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Groups({"prod","product"})
     */
    private $chain;

    /**
     * @Common(cnName="文本显示",listType="text",editType="text",width="")
     * @ORM\Column(type="string", length=255, nullable=true)
     * @Groups({"prod","product"})
     */
    private $text;

    /**
     * @Common(cnName="参数",listType="text",editType="text",width="100")
     * @ORM\Column(type="array", nullable=true)
     * @Groups({"prod","product"})
     */
    private $param = [];

    /**
     * @Common(cnName="是否上架",listType="text",editType="switch",width="100")
     * @ORM\Column(type="boolean")
     * @Groups({"prod","product"})
     */
    private $isOnSale;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getProduct(): ?ShopProduct
    {
        return $this->product;
    }

    public function setProduct(?ShopProduct $product): self
    {
        $this->product = $product;

        return $this;
    }

    public function getNum(): ?float
    {
        return $this->num;
    }

    public function setNum(float $num): self
    {
        $this->num = $num;

        return $this;
    }

    public function getPrice(): ?float
    {
        return $this->price;
    }

    public function setPrice(float $price): self
    {
        $this->price = $price;

        return $this;
    }

    public function getPriceSale(): ?float
    {
        return $this->priceSale;
    }

    public function setPriceSale(?float $priceSale): self
    {
        $this->priceSale = $priceSale;

        return $this;
    }

    public function getPriceCost(): ?float
    {
        return $this->priceCost;
    }

    public function setPriceCost(?float $priceCost): self
    {
        $this->priceCost = $priceCost;

        return $this;
    }

    public function getChain(): ?string
    {
        return $this->chain;
    }

    public function setChain(?string $chain): self
    {
        $this->chain = $chain;

        return $this;
    }

    public function getText(): ?string
    {
        return $this->text;
    }

    public function setText(?string $text): self
    {
        $this->text = $text;

        return $this;
    }

    public function getParam(): ?array
    {
        return $this->param;
    }

    public function setParam(?array $param): self
    {
        $this->param = $param;

        return $this;
    }

    public function getIsOnSale(): ?bool
    {
        return $this->isOnSale;
    }

    public function setIsOnSale(bool $isOnSale): self
    {
        $this->isOnSale = $isOnSale;

        return $this;
    }
}
